package com.smasher.app

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import com.smasher.weight.base.WeightActivity
import com.smasher.weight.entity.WeightEntity

class MainActivity : WeightActivity() {

    override fun initParams(bundle: Bundle?) {
        super.initParams(bundle)
    }

    @SuppressLint("InflateParams")
    override fun getRootView(): View? {
        return layoutInflater.inflate(R.layout.activity_main, null)
    }

    override fun initView() {

    }

    override fun initData() {
        Log.d(TAG, "initData: ")
        startScale()
    }

    override fun handleMessageImmediate(message: String) {
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
    }

    override fun handleWeightConnected() {
        Log.e(CONNECTED, "handleWeightConnected: ")
    }

    override fun handleWeightDisconnected() {
        Log.e(TAG, "handleWeightDisconnected: ")
    }

    override fun onWeightRefresh(entity: WeightEntity, scaleId: String?) {
        //Log.i(TAG, "onWeightRefresh: ${entity.netWeight}")
    }

    override fun onLaunchDelay() {
        Log.d(TAG, "onLaunchDelay:")
        startActivity(Intent().apply {
            setClass(this@MainActivity, MiddleActivity::class.java)
        })
    }

    companion object {
        const val TAG: String = "Main"
        const val CONNECTED: String = "CONNECTED"
    }
}